package com.stars.home.adapter

import android.graphics.Color
import android.text.Spannable
import android.text.SpannableStringBuilder
import android.text.style.ForegroundColorSpan
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder
import com.qmuiteam.qmui.kotlin.onClick
import com.stars.home.R
import com.stars.home.activity.*
import com.stars.home.databinding.ItemRecordBinding
import com.stars.home.model.FeedbackList
import com.trailer.base.base.BAdapter
import com.trailer.base.utils.B
import com.trailer.base.utils.UiSwitch


class RecordAdapter() : BAdapter<FeedbackList, BaseDataBindingHolder<ItemRecordBinding>>(R.layout.item_record) {

    override fun convert(holder: BaseDataBindingHolder<ItemRecordBinding>, item: FeedbackList) {
        holder.dataBinding?.item = item


        if(item.status==1){
            var content="平台回复："+item.replyContent
            //设置
            val builder = SpannableStringBuilder(content)
            val redSpan = ForegroundColorSpan(Color.parseColor("#59C2A3"))
            builder.setSpan(redSpan, 0, 6, Spannable.SPAN_INCLUSIVE_EXCLUSIVE)
            holder.dataBinding?.tvReply?.text=builder
        }
        //设置图片
        var imglist=item.image.split(",")
        var list=ArrayList<String>()
        for(url in imglist){
            list.add(url)
        }
        //设置
        var adpter=ReplyImgAdapter()
        holder.dataBinding?.recyclerView?.adapter=adpter
        adpter.addData(list)


        holder.dataBinding?.ll?.onClick {
            //消息详情
            UiSwitch.bundle(
                context(),
                MsgDetailsActivity::class.java,
                B().putString("id", item.id).ok()
            )
        }


    }
}
